package stage1.module3.homework4;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Delete {
    //若不存在该学号则不变，若存在则删除
    public Delete(ArrayList<Student> students){
        System.out.println("请输入想要删除的学生学号");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        Iterator<Student> iter = students.iterator();
        while(iter.hasNext()){
            Student s = iter.next();
            if(s.getId() == id){
                iter.remove();
                break;
            }
        }
    }
}
